import numpy as np 
import pandas as pd #明天记得看一下pandas
from Loaddata import *
np.set_printoptions(suppress=True)#不以科学计数法输出
if __name__ == "__main__":
    data = Data()
    #按月份分析data.mfd_bank_shibor
    daytime = np.array(data.mfd_bank_shibor["mfd_date"])
    daytime_number = np.zeros((14,1))
    daytime = daytime//100
    daytime_label = np.array([201307,201308,201309,201310,201311,201312,201401,201402,201403,201404,201405,201406,201407,201408])
    for i in range(daytime.shape[0]):
        for j in range(daytime_label.shape[0]):
            if daytime[i]==daytime_label[j]:
                daytime_number[j] = daytime_number[j] + 1
                break 
    print("------------------")
    print("按月份分析data.mfd_bank_shibor")
    print(str(np.c_[daytime_label,daytime_number]))#输出第一列为时间 第二列为个数 但是部分月份缺几天 银行利率数据部分缺失

    #按星座分析 user_profile_table
    usertable = np.array(data.user_profile_table)
    star = np.array(list(set(usertable[:,3])))
    star_number = np.zeros((star.shape[0],1))
    for i in range(usertable.shape[0]):
        for j in range(star.shape[0]):
            if usertable[i,3] == star[j]:
                star_number[j] = star_number[j]+1
                break
    print("------------------")
    print("按星座分析 user_profile_table")
    print(str(np.c_[star,star_number]))

    #按城市分析 user_profile_table
    city = np.array(list(set(usertable[:,2])))
    city_number = np.zeros((city.shape[0],1))
    for i in range(usertable.shape[0]):
        for j in range(city.shape[0]):
            if usertable[i,2] == city[j]:
                city_number[j] = city_number[j]+1
                break
    print("------------------")
    print("按城市分析 user_profile_table")
    print(str(np.c_[city,city_number]))#输出第一列为city编号 第二列为个数 只有7个城市

    #按月份分析mfd_day_share_interest
    Sdaytime = np.array(data.mfd_day_share_interest)
    Sdaytime_number = np.zeros((14,1))
    Sdaytime = Sdaytime//100
    Sdaytime_label = np.array([201307,201308,201309,201310,201311,201312,201401,201402,201403,201404,201405,201406,201407,201408])
    for i in range(Sdaytime.shape[0]):
        for j in range(Sdaytime_label.shape[0]):
            if Sdaytime[i,0]==Sdaytime_label[j]:
                Sdaytime_number[j] = Sdaytime_number[j] + 1
                break 
    print("------------------")
    print("按月分析mfd_day_share_interest")
    print(str(np.c_[Sdaytime_label,Sdaytime_number]))#输出第一列为时间 第二列为个数

    person_table = data.user_profile_table
    person_table = person_table.sort_values(by=["user_id"])
    person_table.to_csv(r'chenguoqi/person_table.csv',encoding="utf_8_sig",index=False)